<?php 
/***
* Create HTML Tag with data select form data input
* @author DuongNV
* @copyright Tan MA JSC
* @category include utility function
* @version 1.1
*/


/**
 * create select tage form title ID
 * @param $id is the name of tag
 * @param $class is class css of tag
 * @param $data
 * @param $selected
 */
function createSelectTagFormData($id, $class, $data, $selected, $onchange = "") {

	// onpen select tag
	$selectTag = "<select id=\"" . $id . "\" class=\"" . $class . "\" name=\"" . $id . "\" onchange=\"$onchange\">";

	foreach ( $data as $key => $value ) {
		if ($key == $selected) {
			$selectTag .= "<option value=\"" . $key . "\" selected=\"true\">";
			$selectTag .= $value;
			$selectTag .= "</option>";
		} else {
			$selectTag .= "<option value=\"" . $key . "\">";
			$selectTag .= $value;
			$selectTag .= "</option>";
		}
	}

	// colse select tag
	$selectTag .= "</select>";

	return $selectTag;
}

/**
 * create option tag
 * @param $id is the name of tag
 * @param $class is class css of tag
 * @param $data is array data to make option
 * @param $selected is value selected of select tag
 * @return $optionTag is a string content select html tag
 */
function createRadioBox($id, $class, $data, $selected) {

	// create radio group
	$radioBox = "";

	// fill data
	foreach ( $data as $key => $value ) {
		if ($key == $selected) {
			$radioBox .= "<label><input type=\"radio\" name=\"" . $id . "\" class=\"" . $class . "\" value=\"" . $key . "\" checked> " . $value . " </label>";
		} else {
			$radioBox .= "<label><input type=\"radio\" name=\"" . $id . "\" class=\"" . $class . "\" value=\"" . $key . "\"> " . $value . " </label>";
		}
	}

	return $radioBox;
}
?>
